package xhwl.insurance.http.api;

import com.google.gson.Gson;

import okhttp3.RequestBody;
import rx.Observable;
import xhwl.insurance.Constant;
import xhwl.insurance.MyApp;
import xhwl.insurance.http.ApiService;
import xhwl.retrofitrx.BaseApi;

/**
 * Created by admin on 2017/6/6.
 */

public class LoginApiV2 extends BaseApi {
    LoginRequest req;

    public LoginApiV2(String member_mobile, String phone_code, String phone_id) {
        req = new LoginRequest(member_mobile, phone_code,phone_id);
    }

    @Override
    protected Observable getObservable() {
        RequestBody requestBody = RequestBody.create(okhttp3.MediaType.parse("application/json; charset=utf-8"), new Gson().toJson(req));
        return retrofit.create(ApiService.class).authCodeLogin(requestBody);
    }

    class LoginRequest {

        public String member_mobile;
        public String phone_code;
        public String yw_id;
        public String phone_id;
        public String lat_point;
        public String lng_point;
        public String cilent_type;

        public LoginRequest(String member_mobile, String phone_code, String phone_id) {
            this.member_mobile = member_mobile;
            this.phone_code = phone_code;
            this.yw_id = Constant.YW_ID;
            this.phone_id = phone_id;
            this.lat_point = MyApp.lat+"";
            this.lng_point = MyApp.lng+"";
            this.cilent_type=Constant.CLIENT_TYPE;
        }
    }
}
